package ar.uba.fi.RSACryptoFiuba.view.decrypt;

import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.TitledBorder;

import ar.uba.fi.RSACryptoFiuba.view.commons.NavigableKeyActionListener;


@SuppressWarnings("serial")
public class DecryptProgressPanel extends JPanel {
	
	private JLabel cryptogramLabel;
	private JTextField cryptogramValue;
	private JLabel numericalRepresentationLabel;
	private JTextField numericalRepresentationValue;
	private JLabel privateKeyLabel;
	private JTextField privateKeyValue;
	private JLabel messageLabel;
    private JTextField messageValue;
	
    public DecryptProgressPanel(){
    	super();
		initComponentes();
	}
		
	private void initComponentes(){
		
        this.setBorder(BorderFactory.createTitledBorder(null, "Progreso", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION));
        this.setToolTipText("");

        cryptogramLabel = new JLabel();
        cryptogramLabel.setFont(new Font("Ubuntu", 1, 15));
        cryptogramLabel.setText("Criptograma:");

        cryptogramValue = new JTextField(6);
        cryptogramValue.setBackground(getBackground());
        cryptogramValue.setBorder(BorderFactory.createEmptyBorder());
        cryptogramValue.addKeyListener(new NavigableKeyActionListener());
        
        numericalRepresentationLabel = new JLabel();
        numericalRepresentationLabel.setFont(new Font("Ubuntu", 1, 15));
        numericalRepresentationLabel.setText("Rep Numérica:");
        
        numericalRepresentationValue = new JTextField(6);
        numericalRepresentationValue.setBackground(getBackground());
        numericalRepresentationValue.setBorder(BorderFactory.createEmptyBorder());
        numericalRepresentationValue.addKeyListener(new NavigableKeyActionListener());
        
        privateKeyLabel = new JLabel();;
        privateKeyLabel.setFont(new Font("Ubuntu", 1, 15));
        privateKeyLabel.setText("Clave Privada:");
        
        privateKeyValue = new JTextField(6);
        privateKeyValue.setBackground(getBackground());
        privateKeyValue.setBorder(BorderFactory.createEmptyBorder());
        privateKeyValue.addKeyListener(new NavigableKeyActionListener());
        
        messageLabel = new JLabel();
        messageLabel.setFont(new Font("Ubuntu", 1, 15));
        messageLabel.setText("Mensaje:");

        messageValue = new JTextField(6);
        messageValue.setBackground(getBackground());
        messageValue.setBorder(BorderFactory.createEmptyBorder());
        messageValue.addKeyListener(new NavigableKeyActionListener());
        
        GroupLayout decryptProgressPanelLayout = new GroupLayout(this);
        this.setLayout(decryptProgressPanelLayout);
        decryptProgressPanelLayout.setHorizontalGroup(
            decryptProgressPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(decryptProgressPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(decryptProgressPanelLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(cryptogramLabel)
                    .addComponent(numericalRepresentationLabel))
                .addPreferredGap(ComponentPlacement.RELATED)
                .addGroup(decryptProgressPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(cryptogramValue, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(numericalRepresentationValue, GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(decryptProgressPanelLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(privateKeyLabel)
                    .addComponent(messageLabel))
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addGroup(decryptProgressPanelLayout.createParallelGroup(Alignment.LEADING, false)
                    .addComponent(privateKeyValue,GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                    .addComponent(messageValue, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        decryptProgressPanelLayout.setVerticalGroup(
            decryptProgressPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(decryptProgressPanelLayout.createSequentialGroup()
                .addGroup(decryptProgressPanelLayout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(cryptogramLabel)
                    .addComponent(cryptogramValue)
                    .addComponent(privateKeyLabel)
                    .addComponent(privateKeyValue))
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addGroup(decryptProgressPanelLayout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(numericalRepresentationLabel)
                    .addComponent(numericalRepresentationValue)
                    .addComponent(messageLabel)
                    .addComponent(messageValue))
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        
	}

	public String getCryptogramValue() {
		return cryptogramValue.getText();
	}

	public void setCryptogramValue(String cryptogramValue) {
		this.cryptogramValue.setText(cryptogramValue);
	}

	public String getNumericalRepresentationValue() {
		return numericalRepresentationValue.getText();
	}

	public void setNumericalRepresentationValue(String numericalRepresentationValue) {
		this.numericalRepresentationValue.setText(numericalRepresentationValue);
	}

	public String getPrivateKeyValue() {
		return privateKeyValue.getText();
	}

	public void setPrivateKeyValue(String privateKeyValue) {
		this.privateKeyValue.setText(privateKeyValue);
	}

	public String getMessageValue() {
		return messageValue.getText();
	}

	public void setMessageValue(String messageValue) {
		this.messageValue.setText(messageValue);
	}
	
}	


